#include "MineCalendar.h"
MineCalendar::MineCalendar(void){}
MineCalendar::~MineCalendar(void){}

bool holiday(string s,int i){
	if(s=="December"&&i==25){
		return true;
	}else if(s=="July"&&i==4){
		return true;
	}else if(s=="December"&&i==25){
		return true;
	}else if(s=="October"&&i==15){
		return true;
	}else if(s=="October"&&i==1){
		return true;
	}else return false;
}
bool holiday2(string s,int wee,int nwee){
	if(s=="November"&&wee==5&&nwee==4){
		return true;
	}else return false;
}
int write(string s,int num, int max){
	cout<< "  "<< s << endl;
	cout<<"Sun Mon Tue Wed Thu Fri Sat"<<endl;
	for(int i=0;i<num;i++){
		cout<< "    ";
	}
	int i;
	for(i=1;i<=max;i++){
		if(i<10){cout<<" ";}
		if(holiday(s,i)||holiday2(s,(i+num)%7,(int)((i+num)/7))){cout<< "{"<<i<<"}";}
		else {cout<< " "<<i<<" ";}
		if ((i+num)%7==0){cout<<endl;}
	}
	cout<<endl<<endl;
	return (i+num-1)%7;
}
void main(){
	int num;
	int leap;
	int year;
	cout<< "Insert the year: ";
	cin >> year;
	leap = (year%4==0)?1:0;
	year = year-2012;
	if (year < 0){
		num=0;
		for(int i=-1;i>=year;i--){
			num += (((-i)%4==0)?366:365);
		}
		num = 7-num%7;
	}else{
		num=0;
		for(int i=0;i<year;i++){
			num += ((i%4==0)?366:365);
		}
		num = num%7;
	}
	/*cout<< "Enter the code number for the day of the week for January 1 as follows:"<< endl;
	cout<< "0- Sun"<< endl;
	cout<< "1- Mon"<< endl;
	cout<< "2- Tue"<< endl;
	cout<< "3- Wed"<< endl;
	cout<< "4- Thu"<< endl;
	cout<< "5- Fri"<< endl;
	cout<< "6- Sat"<< endl;
	cout<< "Enter day code now (0 - 6) ";
	cin >> num;
	cout<< "Is the calendar for a leap year? (enter 1 for yes, 0 for no) ";
	cin >> leap;*/
	cout<< endl<<"*** CALENDAR ***"<< endl<<endl;
	num =write("January",num,31);
	num =write("February",num,28+leap);
	num =write("March",num,31);
	num =write("April",num,30);
	num =write("May",num,31);
	num =write("June",num,30);
	num =write("July",num,31);
	num =write("August",num,31);
	num =write("September",num,30);
	num =write("October",num,31);
	num =write("November",num,30);
	num =write("December",num,31);
	cin >> num;
}